﻿package plugin.instances.game
{
    import com.core.*;
    import com.sh.game.util.*;
    import flash.utils.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.instances.*;
    import uiresource.instances.ui.*;
    import view.mornExtends.*;

    public class UnionBossGame extends HhbossUI implements IInstance
    {

        public function UnionBossGame()
        {
            return;
        }// end function

        public function initShow(param1:Object, param2:Dictionary) : void
        {
            if (param2[InstancesPublic.UNIONBOSSREWARD])
            {
                this.updateShow(InstancesPublic.UNIONBOSSREWARD, param2[InstancesPublic.UNIONBOSSREWARD]);
            }
            shuoming.toolTip = param1.tips.replace(/#""#/g, "\n");
            this.showItem(param1.show);
            return;
        }// end function

        private function showItem(param1:String) : void
        {
            var _loc_2:* = new ItemSplit();
            var _loc_3:* = _loc_2.doSplits(param1, "&", "/", "#");
            list.array = _loc_3[0];
            list.renderHandler = new Handler(this.itemRender);
            return;
        }// end function

        private function itemRender(param1:Component, param2:int) : void
        {
            if (param2 < list.length)
            {
                (param1 as FlashItem).data = list.array[param2];
            }
            return;
        }// end function

        public function updateShow(param1:int, param2:Object) : void
        {
            switch(param1)
            {
                case InstancesPublic.TIMECHECKER:
                {
                    txt_time.text = TimeDataFormatUtil.getLeftTime(int(param2));
                    break;
                }
                case InstancesPublic.UNIONBOSSREWARD:
                {
                    txt_contribution.text = param2.num + "";
                    switch(int(param2.bossState))
                    {
                        case 1:
                        {
                            txt_state.text = "<font color=\'#53b436\'>已出现</font>";
                            break;
                        }
                        case 2:
                        {
                            txt_state.text = "<font color=\'#c72514\'>已击杀</font>";
                            break;
                        }
                        default:
                        {
                            txt_state.text = "<font color=\'#c72514\'>未刷新</font>";
                            break;
                            break;
                        }
                    }
                    txt_num.text = param2.leftMonster;
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function destroyShow(param1:Dictionary) : void
        {
            return;
        }// end function

        public function initEvent() : void
        {
            btn_tuichu.clickHandler = new Handler(this.doTuichu);
            return;
        }// end function

        private function doTuichu() : void
        {
            ModelProxy.change("zone", "exitInstance", null);
            return;
        }// end function

        public function removeEvent() : void
        {
            return;
        }// end function

    }
}
